<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Watson\Validating\ValidatingTrait;

class WorksGroup extends Model
{
    use SoftDeletes;
    use ValidatingTrait;

    protected $table = 'xyj_works_group';

    protected $fillable = ['award_id', 'proposition_company_id' , 'works_type_id' , 'works_count' , 'groups_count' , 'vote_award_id'];

    protected $rules = [
        'award_id'                      => 'required',
        'proposition_company_id'        => 'required',
        'works_type_id'                 => 'required',
        'vote_award_id'                 => 'required',
        'works_count'                   => 'required',
        'groups_count'                  => 'required',
    ];

    protected $validationMessages = [
        'award_id.required'                       => '赛事必填',
        'proposition_company_id.required'         => '命题必填',
        'works_type_id.required'                  => '作品类别必填',
        'vote_award_id.required'                  => '奖项必填',
        'groups_count.required'                   => '分组数目必填',
        'works_count.required'                    => '作品数目必填',
    ];


    /**
     * 赛事
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function award()
    {
        return $this->belongsTo('\App\Models\Award', 'award_id');
    }

    /**
     * 命题
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function company()
    {
        return $this->belongsTo('\App\Models\PropositionCompany', 'proposition_company_id');
    }

    /**
     * 作品类别
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function worksTypes()
    {
        return $this->belongsTo('\App\Models\WorksType', 'works_type_id');
    }

    /**
     * 获奖奖项
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function voteAward()
    {
        return $this->belongsTo('\App\Models\VoteAward', 'vote_award_id');
    }

}
